package com.webbei.xixiaoming.action;

import org.apache.struts2.ServletActionContext;

import com.webbei.shoppingCar.service.shoppingCarService;
import com.webbei.xixiaoming.service.xixiaomingService;

public class changDefaultDisplayPic {
	private String picture;
	private Long id;
	private String type;
	private xixiaomingService xixiSer;
	private shoppingCarService scs;
	private int flag;
	public String execute(){
		String orderPic=null;
		if(type.equals("o")){
			orderPic=scs.getOrdersById(id).getOrderPic();
		}else{
			orderPic=scs.getCustomsById(id).getCustomPic();
		}
		if(orderPic.equals(picture)){
			flag=0;
		}else{
			if(!picture.contains("taobaocdn")){
				String username=(String) ServletActionContext.getContext().getSession().get("username");
				picture="img/resources/webbeiUserInfo/"+username+"/userCustom/"+picture.split("/")[picture.split("/").length-1];
			}
			xixiSer.updateOrderPic(id,type,picture);
			flag=1;
		}
		return "success";
	}

	public String getPicture() {
		return picture;
	}

	public void setPicture(String picture) {
		this.picture = picture;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

//	public xixiaomingService getXixiSer() {
//		return xixiSer;
//	}

	public void setXixiSer(xixiaomingService xixiSer) {
		this.xixiSer = xixiSer;
	}

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public void setScs(shoppingCarService scs) {
		this.scs = scs;
	}
}
